// <copyright file="PartialSelection.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//---------------------------------------------------------------------

namespace Microsoft.Data.OData.Query.SemanticAst
{
    using System.Collections.Generic;

    /// <summary>
    /// Class that represents a partial subset of items on a given type that have been selected at this level of the select expand tree.
    /// </summary>
    internal sealed class PartialSelection : Selection
    {
        /// <summary>
        /// The subset of items that has been selected at this level.
        /// </summary>
        private readonly IEnumerable<SelectItem> selectedItems;

        /// <summary>
        /// Creates a <see cref="PartialSelection"/> with the specified set of <see cref="SelectItem"/>.
        /// </summary>
        /// <param name="selectedItems">The list of items on the that has been selected.</param>
        public PartialSelection(IEnumerable<SelectItem> selectedItems)
        {
            DebugUtils.CheckNoExternalCallers();
            this.selectedItems = selectedItems ?? new SelectItem[0];
        }

        /// <summary>
        /// The subset of items that has been selected at this level.
        /// </summary>
        public IEnumerable<SelectItem> SelectedItems
        {
            get
            {
                DebugUtils.CheckNoExternalCallers(); 
                return this.selectedItems;
            }
        }
    }
}